package com.example.domain.entity;

import javax.persistence.*;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 购物车项实体类
 */
@Data
@Entity
@Table(name = "cart_items")
public class CartItem {

    @Id
    @Column(name = "id", length = 26)
    private String id;

    @Column(name = "cart_id", length = 26, nullable = false)
    private String cartId;

    @Column(name = "product_id", length = 26, nullable = false)
    private String productId;

    @Column(name = "quantity_value", precision = 18, scale = 6, nullable = false)
    private BigDecimal quantityValue;

    @Column(name = "quantity_unit", length = 20, nullable = false)
    private String quantityUnit;

    @CreationTimestamp
    @Column(name = "created_at", updatable = false)
    private LocalDateTime createdAt;

    @UpdateTimestamp
    @Column(name = "updated_at")
    private LocalDateTime updatedAt;
}

